package com.linln.admin.metadata.template.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linln.common.enums.StatusEnum;
import com.linln.common.utils.StatusUtil;
import com.linln.modules.system.domain.User;
import lombok.Data;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;

/**
 * @author leuyius
 * @date 2020/03/18
 */
@Data
@Entity
@Table(name="sys_metadata_template")
@EntityListeners(AuditingEntityListener.class)
@Where(clause = StatusUtil.NOT_DELETE)
public class MetadataTemplateDO implements Serializable {
    // 主键ID
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    private String name;
    // 模板显示名称
    private String viewName;
    // 模板类型
    private Byte systemTemplate;
    // 模板文件名字
    private String templateFileName;
    // 模板文件存放路径
    private String templateFilePath;
    // 实体类字段模板
    private Integer templateType;
    // 数据状态
    private Byte status = StatusEnum.OK.getCode();
    // 模板内容
    private String value;
    // 备注
    private String remark;
    @CreatedDate
    private Date createTime;
    @LastModifiedDate
    private Date updateTime;
    @CreatedBy
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "create_user")
    @JsonIgnore
    private User createUser;
    @LastModifiedBy
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "update_user")
    @JsonIgnore
    private User updateUser;
}